import type { AnyObject } from '@/api/type'
import { CheckboxValueType } from 'element-plus'
import { Component } from 'vue'
export interface FormDataDto {
    id?: number | string
    size?: 'large' | 'small' | 'default'
    span?: number
    labelWidth?: number | string
    inline?: boolean
    labelPosition?: 'left' | 'right' | 'top'
    hideRequiredAsterisk?: boolean // 是否隐藏必填星号
    requireAsteriskPosition?: 'left' | 'right' // 必填星号位置
    list: {
        [key: string]: FormItemDto
    }
}

export interface DefaultAttrsDto {
    label: string,
    value: string | number
}

/**
 * class: 'width-full' 针对于type为date的，element默认给了宽度
 * limitSize: 限制图片上传大小
 * withBase64Header: base64要不要前面的一串头部
 * limit: 图片上传限制张数
 */
export interface ExtraDto {
    maxlength?: number
    showWordLimit?: boolean
    class?: 'width-full' | 'round' | string
    format?: string
    valueFormat?: string
    suffix?: string
    prefix?: string
    min?: number
    max?: number
    append?: FormItemDto
    prepend?: FormItemDto
    limitSize?: number
    limit?: number
    withBase64Head?: boolean
    hint?: string
    activeColor?: string
    inactiveColor?: string
}

export interface FormItemDto {
    label?: string
    name?: string  // 同label 兼容之前的数据 
    prop: string
    span?: number
    type?: string
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    value?: any
    inputType?: string
    dateType?: 'date' | 'year' | 'years' | 'month' | 'months' | 'dates' | 'week' | 'datetime' | 'datetimerange' | 'daterange' | 'monthrange'
    defaultValue?: string | number | boolean | AnyObject | Array<AnyObject>
    placeholder?: string
    disabled?: boolean
    readonly?: boolean
    multiple?: boolean
    required?: boolean
    hide?: boolean
    suffixIcon?: string | Component
    options?: AnyObject[]
    defaultAttrs?: DefaultAttrsDto
    rules?: AnyObject[]
    extra?: ExtraDto & AnyObject
    filterable?: boolean
    remote?: boolean
    noEmit?: boolean
    callbacks?: {
        handleInput?: (value?: string | number) => void
        handleChange?: (value?: CheckboxValueType | CheckboxValueType[]) => void
        handleBlur?: (event?: FocusEvent) => void
        handleFocus?: (item?: FormItemDto, event?: FocusEvent) => void
        remoteMethod?: (value?: string | number) => void
    }
}